//by Tankbuster
//#define __DEBUG__
#define THIS_FILE "fn_clearlandmines.sqf"
#include "x_setup.sqf"
private ["_mpos", "_endtime", "_activecount", "_mines"];
if !(call FUNC(checkSHC)) exitWith {};
PARAMS_3(_mpos,_endtime,_mines);

while {!GVAR(sm_resolved)} do {
	sleep 5;
	if (time > _endtime) exitWith {
		GVAR(sm_winner) = -881;
		GVAR(sm_resolved) = true;
		//diag_log "***time ran out";
	};
	_activecount = {mineActive _x} count _mines;

	if (_activecount == 0) exitWith {
		GVAR(sm_winner) = 2;
		GVAR(sm_resolved) = true;
		//diag_log "***all mines cleared";
	};
};

[QGVAR(sm_var), GVAR(sm_winner)] call FUNC(NetCallEventCTS);

sleep 5;

{
	deleteVehicle _x;
} forEach _mines;

//finished line -882 is youve died need to add in as failure or a mine has exploded to prevent not using a mine detector
